app.controller('RoleModalCtrl', function ($scope, $modalInstance, toaster, param) {

	$scope.submitting = false;
	$scope.param = param;
	if ($scope.param.data == null) {
		$scope.param.data = {};
	}

	if ($scope.param.type == 'insert') {
		$scope.flag = true;
	}

	$scope.ok = function () {
		if ($scope.myForm.$valid) {
			var code = $scope.param.data.code;
			var strs = code.split("_");
			if (strs[0] != "ROLE") {
				toaster.pop('warning', '提示', '角色编码格式有误，请重新输入！');
				return;
			}
			$modalInstance.close($scope.param);
		}
	};

	$scope.cancel = function () {
		$modalInstance.dismiss('cancel');
		$scope.submitting = false;
	};
});